package com.example.departmentService.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.departmentService.entity.ProjectInfo;
import com.example.departmentService.entity.ProjectMember;
import com.example.departmentService.entity.ResumeBlock;
import com.example.departmentService.entity.dto.ResumeConditons;
import com.example.departmentService.entity.vo.ProjectListVo;
import com.example.departmentService.mapper.ResumeBlockMapper;
import com.example.departmentService.service.IResumeBlockService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.*;

@Service
public class ResumeBlockServiceImpl extends ServiceImpl<ResumeBlockMapper, ResumeBlock> implements IResumeBlockService {
    @Resource
    private ResumeBlockMapper resumeBlockMapper;

    @Override
    public List<ResumeBlock> findAll() {
        List<ResumeBlock> resumeBlocks = resumeBlockMapper.selectList(null);
        return resumeBlocks;
    }

    @Override
    public Integer insert(ResumeBlock resumeBlock) {
        ResumeBlock resumeBlock1 = new ResumeBlock();
        resumeBlock1.setPersonAge(resumeBlock.getPersonAge());
        resumeBlock1.setPersonEducation(resumeBlock.getPersonEducation());
        resumeBlock1.setPersonGender(resumeBlock.getPersonGender());
        resumeBlock1.setPersonMatch(resumeBlock.getPersonMatch());
        resumeBlock1.setPersonName(resumeBlock.getPersonName());
        resumeBlock1.setScore(resumeBlock.getScore());
        int item = resumeBlockMapper.insert(resumeBlock1);
        return item;
    }

    @Override
    public List<ResumeBlock> selectList(ResumeConditons resumeConditons) {
//        resumeConditons.setPersonEducation("本科");
//        resumeConditons.setPersonGender("男");

//        Map<String, Object> columnMap = new HashMap<>();
//        columnMap.put("PERSON_GENDER", resumeConditons.getPersonGender());
//        columnMap.put("PERSON_EDUCATION", resumeConditons.getPersonEducation());
//        List<ResumeBlock> resumeBlocks = resumeBlockMapper.selectByMap(columnMap);

        QueryWrapper<ResumeBlock> wrapper = new QueryWrapper<>();
            wrapper.eq(resumeConditons.getPersonGender()!=null,"PERSON_GENDER", resumeConditons.getPersonGender())
                    .or().eq(resumeConditons.getPersonEducation()!=null,"PERSON_EDUCATION",resumeConditons.getPersonEducation());
        List<ResumeBlock> resumeBlocks = resumeBlockMapper.selectList(wrapper);
        return resumeBlocks;
    }


}
